export const logTimeOut = {
  data() {
    return {
      seconds: 3,
      showJumpAlert: false,
      timer: null
    }
  },
  methods: {
    // 判断登陆是否超时
    handleLoginTimeOut() {
      // 跳转到登陆
      this.showJumpAlert = true
      this.timer !== null && clearInterval(this.timer)
      this.timer = setInterval(() => {
        this.seconds--
        if (this.seconds === 0) {
          this.$router.push('/login')
          clearInterval(this.timer)
        }
      }, this.seconds * 1000)
    },
    // 取消跳转
    cancelJumpToLogin() {
      clearInterval(this.timer)
      this.showJumpAlert = false
      this.seconds = 3
    },
    // 立即跳转
    jumpToLogin() {
      this.cancelJumpToLogin()
      this.$router.push('/login')
    }
  }
}
